from typing import List, Any

import requests
class WeatherAPIUtil:
    def __init__(self,
                 baseUrl: str= 'https://weather.cma.cn/api/now/',
                 timeOut:int=10
    ):
        self.baseUrl = baseUrl

    def getWeather(self,stationId:str) -> list[Any]:
        self.requestUrl = self.baseUrl + str(stationId)
        response=requests.get(self.requestUrl)
        if response.status_code == 200:
            self.weatherData = response.json()['data']
            return [
                self.weatherData['location']['name'],
                self.weatherData["now"]["precipitation"],
                self.weatherData["now"]["temperature"],
                self.weatherData["now"]["pressure"],
                self.weatherData["now"]["humidity"],
                self.weatherData["now"]["windDirection"],
                self.weatherData["now"]["windDirectionDegree"],
                self.weatherData["now"]["windSpeed"],
                self.weatherData["now"]["windScale"],
                self.weatherData["now"]["feelst"],
            ]
        else:
            self.weatherData = None
            print(f"接口访问错误{self.requestUrl}")
            return []

if __name__ == '__main__':
    w=WeatherAPIUtil()
    print(w.getWeather("565386"))